package com.hyzh.latte.vehicle.nezha;

import com.github.benmanes.caffeine.cache.Expiry;
import com.hyzh.latte.vehicle.dmo.VehicleBO;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.nullness.qual.NonNull;

import java.util.concurrent.TimeUnit;

/**
 * @author songkui
 * @since 2024/7/18 19:20
 */
public class VehicleExpiry implements Expiry<String, VehicleBO> {
    @Override
    public long expireAfterCreate(@NonNull String key, @NonNull VehicleBO value, long currentTime) {
        return TimeUnit.SECONDS.toNanos(60);
    }

    @Override
    public long expireAfterUpdate(@NonNull String key, @NonNull VehicleBO value, long currentTime, @NonNegative long currentDuration) {
        return currentDuration;
    }

    @Override
    public long expireAfterRead(@NonNull String key, @NonNull VehicleBO value, long currentTime, @NonNegative long currentDuration) {
        return currentDuration;
    }
}
